package com.vilen.cms.model;

import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;

/**
 * Created by vilen on 2017/2/11.
 */
@Entity
@Table(name = "t_channel")
public class Channel {

    public static final String ROOT_NAME="网站系统栏目";
    public static final int ROOT_ID=0;

    private int id;
    private String name;
    /**
     * 是否是自定义链接
     */
    private int customLink;
    /**
     * 自定义链接地址
     */
    private String customLinkUrl;
    /**
     * 栏目的类型 enum 枚举类型
     */
    private ChannelType type;
    /**
     * 首页栏目 0 否 1是
     */
    private int isIndex;
    /**
     * 顶部导航栏目 0 否 1是
     */
    private int isTopNav;
    /**
     * 推荐栏目 0 否 1是
     */
    private int recommend;
    private int status;
    /**
     * 栏目序号
     */
    private int orders;
    /**
     * 父类栏目
     */
    private Channel parent;

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @NotEmpty(message = "栏目名称不能为空")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "custom_link")
    public int getCustomLink() {
        return customLink;
    }

    public void setCustomLink(int customLink) {
        this.customLink = customLink;
    }

    @Column(name = "custom_link_url")
    public String getCustomLinkUrl() {
        return customLinkUrl;
    }

    public void setCustomLinkUrl(String customLinkUrl) {
        this.customLinkUrl = customLinkUrl;
    }

    public ChannelType getType() {
        return type;
    }

    public void setType(ChannelType type) {
        this.type = type;
    }

    @Column(name = "is_index")
    public int getIsIndex() {
        return isIndex;
    }

    public void setIsIndex(int isIndex) {
        this.isIndex = isIndex;
    }

    @Column(name = "is_top_nav")
    public int getIsTopNav() {
        return isTopNav;
    }

    public void setIsTopNav(int isTopNav) {
        this.isTopNav = isTopNav;
    }

    public int getRecommend() {
        return recommend;
    }

    public void setRecommend(int recommend) {
        this.recommend = recommend;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getOrders() {
        return orders;
    }

    public void setOrders(int orders) {
        this.orders = orders;
    }

    @ManyToOne
    @JoinColumn(name = "pid")
    public Channel getParent() {
        return parent;
    }

    public void setParent(Channel parent) {
        this.parent = parent;
    }
}
